<template lang="pug">
  .container.homework__main
    .row.content__head
      .col-sm-3
        h2.side__menu__textbook 课本
        .side__menu__switch.float-right(@click="selectBook")
          i.icon_switch_normal
          | 切换
      .col-sm-9
        h2.content__filter__title 内容
          small （共2345个资源）
        .content__filter
          .content__filter__date 2017.9.12-2017.9.12
          .content__filter__order 时间顺序
      .col-sm-12
        .split
    .row
      .col-sm-3
        h3.side__menu__dt 高二课本
        ul.side__menu__list
          li(v-for="item in books", v-if="item.level === 1")
            router-link.side__menu__sub.expand(:to="'/student/tutorship/' + item.catalogId") {{item.catalogName}}
            ul(v-for="level2 in books", v-if="level2.level === 2")
              li
                router-link.side__menu__sub(:to="'/student/tutorship/' + level2.catalogId") {{level2.catalogName}}
                ul(v-for="level3 in books", v-if="level3.level === 3 && level3.parentId === level2.catalogId")
                  li
                    router-link(:to="'/student/tutorship/' + level3.catalogId") {{level3.catalogName}}
      .col-sm-9
        table.homework__tb
          tr
            td 作业名称
            td 作业状态
            td 创建时间
            td 操作
          tr(v-for="item in list", @click="toDetail(item)")
            td {{item.homeworkName}}
            td {{item.homeworkStatus}}
            td {{item.startTime}}
            td 
              a(href="") 导出题目
        page
</template>
<script>
import api from 'api/student/tutorship'
import lession from 'api/lession'
export default {
  data () {
    return {
      list: [],
      books: []
    }
  },
  mounted () {
    api.getList('174169822383308800', this.$root.user.id).then((Response) => {
      const data = Response.data
      this.list = data.data.list
    })
    this.getBooks()
  },
  methods: {
    toDetail (item) {
      this.$router.push('/student/tutorship/' + item.homeworkId)
    },
    getBooks () {
      lession.getBooks('119907809079853056').then((response) => {
        this.books = response.data.data
      })
    },
    selectBook () {
      this.$store.commit('show', 'switchLession')
    }
  }
}
</script>

